﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Control_Layer;

namespace Mindmap_Case_4
{
    /// <summary>
    /// Enumerator for Alternate actions.
    /// </summary>
    public enum Action
    {
        Mindmap,
        File,
        Site
    }

    public partial class Alternate : Form
    {
        private string argument;
        public string Argument
        {
            get { return argument; }
        }

        private Action action;
        public Action GetAction
        {
            get { return action; }
        }

        public Alternate()
        {
            InitializeComponent();

            rbMindmap.Checked = true;

            CCSelectMindmap ccSelectMindmap = new CCSelectMindmap();
            lbxMindmaps.DataSource = ccSelectMindmap.GetMindmaps();
        }

        /// <summary>
        /// Changes Action to Mindmap.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void rbMindmap_CheckedChanged(object sender, EventArgs e)
        {
            lbxMindmaps.Visible = true;
            pnlFile.Visible = false;
            txtSite.Visible = false;

            action = Action.Mindmap;
        }

        /// <summary>
        /// Changes Action to File.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void rbFile_CheckedChanged(object sender, EventArgs e)
        {
            lbxMindmaps.Visible = false;
            pnlFile.Visible = true;
            txtSite.Visible = false;

            action = Action.File;
        }

        /// <summary>
        /// Changes Action to Site.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void rbHttp_CheckedChanged(object sender, EventArgs e)
        {
            lbxMindmaps.Visible = false;
            pnlFile.Visible = false;
            txtSite.Visible = true;

            action = Action.Site;
        }

        /// <summary>
        /// Starts current selected Action when button click occurs.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnOK_Click(object sender, EventArgs e)
        {
            switch (action)
            {
                case Action.Mindmap:
                    argument = lbxMindmaps.SelectedItem.ToString();
                    break;
                case Action.File:
                    argument = txtFile.Text;
                    break;
                case Action.Site:
                    argument = txtSite.Text;
                    break;
            }
        }

        /// <summary>
        /// Opens an Open File Dialog.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnBrowse_Click(object sender, EventArgs e)
        {
            if (ofdFile.ShowDialog() == DialogResult.OK)
            {
                txtFile.Text = ofdFile.FileName;
            }
        }
    }
}
